package com.xjh.him.controller;

import com.xjh.him.annotation.LoginVerify;
import com.xjh.him.dto.friendapply.FriendApplyDTO;
import com.xjh.him.service.FriendApplyServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xjh.tool.dto.PageResultDTO;
import org.xjh.tool.dto.ResultDTO;
import org.xjh.tool.vo.AjaxResultVO;

@RestController
@RequestMapping("/friend/apply")
public class FriendApplyController {

    @Autowired
    private FriendApplyServiceImpl friendApplyService;


    @LoginVerify
    @RequestMapping("/count")
    public AjaxResultVO countApply() {
        ResultDTO<Integer> resultDTO = friendApplyService.countApply();
        if (resultDTO.isSuccess()) {
            return AjaxResultVO.getSuccessResult(resultDTO.getResult());
        }
        return AjaxResultVO.getFailureResult(resultDTO.getErrMsg());
    }

    @LoginVerify
    @RequestMapping("/list")
    public AjaxResultVO listApply() {
        PageResultDTO<FriendApplyDTO> pageResultDTO = friendApplyService.listApply();
        if (pageResultDTO.isSuccess()) {
            return AjaxResultVO.getSuccessResult(pageResultDTO.getPageResult());
        }
        return AjaxResultVO.getFailureResult(pageResultDTO.getErrMsg());
    }
}
